using System;

namespace Predictor
{
	/// <summary>
	/// A class that keeps the usage statistics about the words that were typed
	/// Author: Panos
	/// </summary>
	
	public class Statistics
	{
		private int usageCount;		
		
		public Statistics ()
		{
			usageCount = 0;
		}
		
		
		/// <summary>
		/// This method must be called when the word that the Statistics instance belongs is typed
        /// Author: Panos
		/// </summary>
		
		public void WordTyped()
		{
			usageCount++;
		}


        /// <summary>
        /// Returns how many times the word was typed
        /// Author: Panos
        /// </summary>
        /// <returns></returns>

        public int GetPopularity()
        {
            return usageCount;
        }


		/// <summary>
		/// Parses a string with format <usage_count> and populates the instance with these data
        /// Author: Panos
		/// </summary>
		/// <param name="data">
		/// A <see cref="System.String"/> to be parsed
		/// </param>
		
		public void LoadFromString(string data)
		{
			usageCount = Int32.Parse(data);
		}
		
		
		public override string ToString ()
		{
			return usageCount.ToString();
		}
	}
}

